package com.mooc.kafka.producer;

import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;

import java.util.Map;

/**
 * @author StarsOfFuture_xYang
 * @version 1.0
 * @date 2021-04-06 9:24 下午
 * @information kafka-study - com.mooc.kafka.producer
 **/
public class MySelfProducerPartition implements Partitioner {

    @Override
    public int partition(String s, Object o, byte[] bytes, Object o1, byte[] bytes1, Cluster cluster) {
        return Integer.parseInt(String.valueOf(o).split("-")[1]) % 2;
    }

    @Override
    public void close() {

    }

    @Override
    public void configure(Map<String, ?> map) {

    }

}
